package org.musicsweet.controller;

import org.musicsweet.anotation.AuthReq;
import org.musicsweet.entity.SysDic;
import org.musicsweet.result.ResultData;
import org.musicsweet.service.SysDicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统字典Controller
 */
@RestController
@RequestMapping("/sysDic")
public class SysDicController {

    @Autowired
    private SysDicService sysDicService;

    /**
     * 根据id查询系统字典
     *
     * @param sysDic
     * @return
     */
    @AuthReq
    @RequestMapping("/getSysDicById")
    public ResultData<SysDic> getSysDicById(@RequestBody SysDic sysDic) {
        return sysDicService.getSysDicById(sysDic);
    }

    /**
     * 多条件查询系统字典
     *
     * @param sysDic
     * @return
     */
    @AuthReq
    @RequestMapping("/getSysDicList")
    public ResultData<List<SysDic>> getSysDicList(@RequestBody SysDic sysDic) {
        return sysDicService.getSysDicList(sysDic);
    }


    /**
     * 添加系统字典
     *
     * @param sysDic
     * @param token
     * @return
     */
    @RequestMapping("/addSysDic")
    public ResultData addSysDic(@RequestBody SysDic sysDic, String token) {
        return sysDicService.addSysDic(sysDic, token);
    }


    /**
     * 修改系统字典
     *
     * @param sysDic
     * @param token
     * @return
     */
    @RequestMapping("/updateSysDic")
    public ResultData updateSysDic(@RequestBody SysDic sysDic, String token) {
        return sysDicService.updateSysDic(sysDic, token);
    }


    /**
     * 删除系统字典
     *
     * @param sysDic
     * @return
     */
    @RequestMapping("/delSysDic")
    public ResultData delSysDic(@RequestBody SysDic sysDic) {
        return sysDicService.delSysDic(sysDic);
    }

}